//
//  MapViewController.m
//  myselfTest
//
//  Created by Lucifer on 15-5-20.
//  Copyright (c) 2015年 xuxzhou. All rights reserved.
//

#import "MapViewController.h"
#import "MAMapKit.h"

@interface MapViewController ()<MAMapViewDelegate>
@property(nonatomic,strong)MAMapView * mapView;
@end

@implementation MapViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self buildMapView];

}
-(void)buildMapView{
    [MAMapServices sharedServices].apiKey = @"7c252274b99a9696c6ddd9ec400f8eb6";
    _mapView =[[MAMapView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds))];
    _mapView.delegate=self;
    _mapView.showTraffic = YES;
    _mapView.buildingsDisabled = YES;
    _mapView.showsUserLocation = YES;
    [_mapView setZoomLevel:5 animated:YES];
    _mapView.logoCenter = CGPointMake(-200, 450);
    //iOS SDK默认的Logo为“高德地图v2.x.x”字样，显示在地图的左下方。地图Logo不能移除，但可通过MAMapView.logoCenter属性来调整Logo的显示位置
    _mapView.customizeUserLocationAccuracyCircleRepresentation = YES;
    [self.view addSubview:_mapView];
    
}

-(MAOverlayView *)mapView:(MAMapView *)mapView viewForOverlay:(id<MAOverlay>)overlay{
    /* 自定义定位精度对应的MACircleView. */
    if (overlay == mapView.userLocationAccuracyCircle)
    {
        MACircleView *accuracyCircleView = [[MACircleView alloc] initWithCircle:overlay];
        
        //        accuracyCircleView.lineWidth    = 2.5f;
        accuracyCircleView.fillColor    = [UIColor colorWithRed:0 green:0 blue:1 alpha:.1];//center color
        //        accuracyCircleView.strokeColor = color_hex(0xff5f5a);
        return accuracyCircleView;
    }
    return nil;
}

-(void)mapView:(MAMapView *)mapView didUpdateUserLocation:(MAUserLocation *)userLocation updatingLocation:(BOOL)updatingLocation{
    //        [self addAnnotationsToMap];
    [_mapView setZoomLevel:14.5 animated:YES];
    _mapView.centerCoordinate=CLLocationCoordinate2DMake(userLocation.coordinate.latitude ,userLocation.coordinate.longitude );
    
    //    NSLog(@"%f,%f",userLocation.coordinate.longitude,userLocation.coordinate.latitude);
}
-(void)viewWillDisappear:(BOOL)animated{
    _mapView=nil;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
